/*
 * Copyright (C) 2012 Apple Inc. All rights reserved.
 *
 * This document is the property of Apple Inc.
 * It is considered confidential and proprietary.
 *
 * This document may not be reproduced or transmitted in any form,
 * in whole or in part, without the express written permission of
 * Apple Inc.
 */

#ifndef __DIALOG_D2089_H
#define __DIALOG_D2089_H

#define PMU_HAS_SWI		0
#define PMU_HAS_DWI		1
#define PMU_HAS_LCM_LDO		1
#define PMU_HAS_BIST_ADC	1
#define PMU_HAS_CHG_ABCC_FLAG	1
#define PMU_HAS_VIB		0
#define PMU_HAS_RAM		1
#define PMU_HAS_WLED		1
#define PMU_HAS_32K_RTC		1
// <rdar://problem/12671876>:
#define PMU_HAS_ACCUMULATORS	0

enum {
	kDIALOG_ADDR_R		= 0x79,
	kDIALOG_ADDR_W		= 0x78,
	kDIALOG_REG_BYTES	= 2,
};

enum {
	kDIALOG_EVENT_COUNT		= 14,
	kDIALOG_STATUS_COUNT		= 13,
	kDIALOG_FAULTLOG_COUNT		= 2,
	kDIALOG_CHIPID_COUNT		= 4,
	kDIALOG_GPIO_COUNT		= 17,
};

#include "dCommon.h"

enum {
	kDIALOG_MASK_REV_CODE		= 0x0000,
	kDIALOG_TRIM_REL_CODE		= 0x0001,
	kDIALOG_PLATFORM_ID		= 0x0002,
	kDIALOG_DEVICE_ID1		= 0x0004,
	kDIALOG_DEVICE_ID2		= 0x0005,
	kDIALOG_DEVICE_ID3		= 0x0006,
	kDIALOG_DEVICE_ID4		= 0x0007,
	kDIALOG_DEVICE_ID5		= 0x0008,
	kDIALOG_CHIP_ID			= kDIALOG_MASK_REV_CODE,
	
	kDIALOG_SYS_CONTROL		= 0x0010,
	kDIALOG_SYS_CONTROL2	= 0x0011,
	
	kDIALOG_SYS_CONFIG		= 0x0020,
	kD2089_SYS_CONF_B		= 0x0021,
	kD2089_SYS_CONF_C		= 0x0022,
	kD2089_SYS_CONF_D		= 0x0023,
	kD2089_BG_TRIM			= 0x0024,
	kD2089_VREF_AUX_TRIM	= 0x0025,
	kD2089_VRTC_BG_TRIM		= 0x0026,
	kD2089_VDD_FAULT		= 0x0027,
	kD2089_RTC_CTRL0		= 0x0028,
	kD2089_RTC_CTRL1		= 0x0029,
	kD2089_OSC_CTRL0		= 0x002a,
	kD2089_INT_OSC_TRIM		= 0x002b,
	kD2089_CLK_REQ_FRC		= 0x002c,

	kDIALOG_FAULT_LOG		= 0x0040,
	kDIALOG_FAULT_LOG2		= 0x0041,
	
	kDIALOG_EVENT_A			= 0x0050,
	kDIALOG_EVENT_B			= 0x0051,
	kDIALOG_EVENT_C			= 0x0052,
	kDIALOG_EVENT_D			= 0x0053,
	kDIALOG_EVENT_E			= 0x0054,
	kDIALOG_EVENT_F			= 0x0055,
	kDIALOG_EVENT_G			= 0x0056,
	kDIALOG_EVENT_H			= 0x0057,
	kDIALOG_EVENT_I			= 0x0058,
	kDIALOG_EVENT_J			= 0x0059,
	kDIALOG_EVENT_K			= 0x005a,
	kDIALOG_EVENT_L			= 0x005b,

	kDIALOG_EVENT_M			= 0x005c,
	kDIALOG_EVENT_N			= 0x005d,

	kDIALOG_STATUS_A		= 0x0060,
	kDIALOG_STATUS_B		= 0x0061,
	kDIALOG_STATUS_C		= 0x0062,
	kDIALOG_STATUS_D		= 0x0063,
	kDIALOG_STATUS_E		= 0x0064,
	kDIALOG_STATUS_F		= 0x0065,
	kDIALOG_STATUS_G		= 0x0066,
	kDIALOG_STATUS_H		= 0x0067,
	kDIALOG_STATUS_I		= 0x0068,
	kDIALOG_STATUS_J		= 0x0069,
	kDIALOG_STATUS_K		= 0x006a,
	kDIALOG_STATUS_L		= 0x006b,
	kDIALOG_STATUS_M		= 0x006c,

	kDIALOG_IRQ_MASK_A		= 0x0070,
	kDIALOG_IRQ_MASK_B		= 0x0071,
	kDIALOG_IRQ_MASK_C		= 0x0072,
	kDIALOG_IRQ_MASK_D		= 0x0073,
	kDIALOG_IRQ_MASK_E		= 0x0074,
	kDIALOG_IRQ_MASK_F		= 0x0075,
	kDIALOG_IRQ_MASK_G		= 0x0076,
	kDIALOG_IRQ_MASK_H		= 0x0077,
	kDIALOG_IRQ_MASK_I		= 0x0078,
	kDIALOG_IRQ_MASK_J		= 0x0079,
	kDIALOG_IRQ_MASK_K		= 0x007A,
	kDIALOG_IRQ_MASK_L		= 0x007B,
	kDIALOG_IRQ_MASK_M		= 0x007C,
	kDIALOG_IRQ_MASK_N		= 0x007D,

	kD2089_ACTIVE1			= 0x0080,
	kD2089_ACTIVE2			= 0x0081,
	kD2089_ACTIVE3			= 0x0082,
	kD2089_ACTIVE4			= 0x0083,
	kD2089_ACTIVE5			= 0x0084,
	kDIALOG_LCM_ACTIVE		= kD2089_ACTIVE5,
	kD2089_ACTIVE6			= 0x0085,
	kD2089_ACTIVE7			= 0x0086,
	kD2089_STANDBY1			= 0x0088,
	kD2089_STANDBY3			= 0x008a,
	kD2089_STANDBY4			= 0x008b,
	kD2089_STANDBY6			= 0x008d,
	kD2089_STANDBY7			= 0x008e,
	kD2089_HIBERNATE1		= 0x0090,
	kD2089_HIBERNATE3		= 0x0092,
	kD2089_HIBERNATE4		= 0x0093,
	kD2089_HIBERNATE6		= 0x0095,
	kD2089_HIBERNATE7		= 0x0096,

//--
	
	kD2089_SLOT_TIMINGS		= 0x00a0,
	kD2089_ACT_TO_HIB_DLY	= 0x00a1,
	kD2089_BUCK0_SLOT		= 0x00b0,
	kD2089_BUCK1_SLOT		= 0x00b1,
	kD2089_BUCK2_SLOT		= 0x00b2,
	kD2089_BUCK3_SLOT		= 0x00b3,
	kD2089_BUCK4_SLOT		= 0x00b4,
	kD2089_BUCK5_SLOT		= 0x00b5,
	kD2089_BUCK6_SLOT		= 0x00b6,

	kD2089_LDO1_SLOT		= 0x00c1,
	kD2089_LDO2_SLOT		= 0x00c2,
	kD2089_LDO3_SLOT		= 0x00c3,
	kD2089_LDO4_SLOT		= 0x00c4,
	kD2089_LDO5_SLOT		= 0x00c5,
	kD2089_LDO6_SLOT		= 0x00c6,
	kD2089_LDO7_SLOT		= 0x00c7,
	kD2089_LDO8_SLOT		= 0x00c8,
	kD2089_LDO9_SLOT		= 0x00c9,
	kD2089_LDO10_SLOT		= 0x00ca,
	kD2089_LDO11_SLOT		= 0x00cb,
	kD2089_LDO12_SLOT		= 0x00cc,
	kD2089_LDO13_SLOT		= 0x00cd,
	
	kD2089_LCM_BOOST_SW_SLOT	= 0x00d0,
	kD2089_LCM_BOOST_SLOT		= 0x00d1,
	kD2089_LCM_LDO1_SLOT		= 0x00d2,
	kD2089_LCM_LDO2_SLOT		= 0x00d3,
	kD2089_LCM_LDO3_SLOT		= 0x00d4,
	
	kD2089_CHARGE_PUMP_SLOT		= 0x00d8,
	kD2089_BUCK3_SW1_SLOT		= 0x00d9,
	kD2089_BUCK3_SW2_SLOT		= 0x00da,
	kD2089_BUCK3_SW3_SLOT		= 0x00db,
	kD2089_BUCK4_SW1_SLOT		= 0x00dc,
	kD2089_BUCK4_SW2_SLOT		= 0x00dd,

	kD2089_BUCK_DWI_CTRL0		= 0x00f0,
	kD2089_BUCK_DWI_TRIM0		= 0x00f2,
	kD2089_BUCK_FSM_TRIM0		= 0x00f4,
	kD2089_BUCK_FSM_TRIM1		= 0x00f5,
	kD2089_BUCK_FSM_TRIM2		= 0x00f6,
	kD2089_BUCK_FSM_TRIM3		= 0x00f7,
	
	kD2089_BUCK_CALIB_OFFSET_TRIM	= 0x00f8,
	kD2089_BUCK_DEBUG_OFFSET	= 0x00f9,
	kD2089_BUCK_OFFSET_SEL		= 0x00fa,
	kD2089_BUCK_OFFSET_EN		= 0x00fb,

	kD2089_BUCK0_VSEL		= 0x0100,
	kD2089_BUCK0_VSEL_ACTUAL	= 0x0102,
	kD2089_BUCK0_MINV		= 0x0103,
	kD2089_BUCK0_MAXV		= 0x0104,
	kD2089_BUCK0_OFS_V		= 0x0105,
	kD2089_BUCK0_MODE		= 0x0106,
	kD2089_BUCK0_START_ILIMIT	= 0x0107,
	kD2089_BUCK0_SYNC_ILIMIT	= 0x0108,
	kD2089_BUCK0_SLEEP_ILIMIT	= 0x0109,
	kD2089_BUCK0_FSM_TRIM0		= 0x010a,
	kD2089_BUCK0_FSM_TRIM1		= 0x010b,
	kD2089_BUCK0_FSM_TRIM2		= 0x010c,
	kD2089_BUCK0_FSM_TRIM3		= 0x010d,
	kD2089_BUCK0_CLK_TRIM1		= 0x010e,
	kD2089_BUCK0_CLK_TRIM2		= 0x010f,
	kD2089_BUCK0_CLK_TRIM3		= 0x0110,
	kD2089_BUCK0_CALIB0		= 0x0112,
	kD2089_BUCK0_CALIB1		= 0x0113,
	kD2089_BUCK0_ANA_TRIM0		= 0x0114,
	kD2089_BUCK0_ANA_TRIM1		= 0x0115,
	kD2089_BUCK0_ANA_TRIM2		= 0x0116,
	kD2089_BUCK0_ANA_TRIM3		= 0x0117,
	kD2089_BUCK0_ANA_TRIM4		= 0x0118,
	kD2089_BUCK0_ANA_TRIM5		= 0x0119,
	kD2089_BUCK0_ANA_TRIM6		= 0x011a,
	kD2089_BUCK0_ANA_TRIM7		= 0x011b,
	kD2089_BUCK0_ANA_TRIM8		= 0x011c,
	kD2089_BUCK0_ANA_TRIM9		= 0x011d,
	
	kD2089_BUCK1_VSEL		= 0x0120,
	kD2089_BUCK1_VSEL_ACTUAL	= 0x0122,
	kD2089_BUCK1_MINV		= 0x0123,
	kD2089_BUCK1_MAXV		= 0x0124,
	kD2089_BUCK1_OFS_V		= 0x0125,
	kD2089_BUCK1_MODE		= 0x0126,
	kD2089_BUCK1_START_ILIMIT	= 0x0127,
	kD2089_BUCK1_SYNC_ILIMIT	= 0x0128,
	kD2089_BUCK1_SLEEP_ILIMIT	= 0x0129,
	kD2089_BUCK1_FSM_TRIM0		= 0x012a,
	kD2089_BUCK1_FSM_TRIM1		= 0x012b,
	kD2089_BUCK1_FSM_TRIM2		= 0x012c,
	kD2089_BUCK1_FSM_TRIM3		= 0x012d,
	kD2089_BUCK1_CLK_TRIM1		= 0x012e,
	kD2089_BUCK1_CLK_TRIM2		= 0x012f,
	kD2089_BUCK1_CLK_TRIM3		= 0x0130,
	kD2089_BUCK1_CALIB0		= 0x0132,
	kD2089_BUCK1_CALIB1		= 0x0133,
	kD2089_BUCK1_ANA_TRIM0		= 0x0134,
	kD2089_BUCK1_ANA_TRIM1		= 0x0135,
	kD2089_BUCK1_ANA_TRIM2		= 0x0136,
	kD2089_BUCK1_ANA_TRIM3		= 0x0137,
	kD2089_BUCK1_ANA_TRIM4		= 0x0138,
	kD2089_BUCK1_ANA_TRIM5		= 0x0139,
	kD2089_BUCK1_ANA_TRIM6		= 0x013a,
	kD2089_BUCK1_ANA_TRIM7		= 0x013b,
	kD2089_BUCK1_ANA_TRIM8		= 0x013c,
	kD2089_BUCK1_ANA_TRIM9		= 0x013d,

	kD2089_BUCK2_VSEL		= 0x0140,
	kD2089_BUCK2_VSEL_ACTUAL	= 0x0142,
	kD2089_BUCK2_MINV		= 0x0143,
	kD2089_BUCK2_MAXV		= 0x0144,
	kD2089_BUCK2_OFS_V		= 0x0145,
	kD2089_BUCK2_MODE		= 0x0146,
	kD2089_BUCK2_START_ILIMIT	= 0x0147,
	kD2089_BUCK2_SYNC_ILIMIT	= 0x0148,
	kD2089_BUCK2_SLEEP_ILIMIT	= 0x0149,
	kD2089_BUCK2_FSM_TRIM0		= 0x014a,
	kD2089_BUCK2_FSM_TRIM1		= 0x014b,
	kD2089_BUCK2_FSM_TRIM2		= 0x014c,
	kD2089_BUCK2_FSM_TRIM3		= 0x014d,
	kD2089_BUCK2_CLK_TRIM		= 0x014e,
	kD2089_BUCK2_CALIB0		= 0x0150,
	kD2089_BUCK2_ANA_TRIM0		= 0x0152,
	kD2089_BUCK2_ANA_TRIM1		= 0x0153,
	kD2089_BUCK2_ANA_TRIM2		= 0x0154,
	kD2089_BUCK2_ANA_TRIM3		= 0x0155,

	kD2089_BUCK3_VSEL		= 0x0160,
	kD2089_BUCK3_VSEL_ALT		= 0x0161,
	kD2089_BUCK3_VSEL_ACTUAL	= 0x0162,
	kD2089_BUCK3_MINV		= 0x0163,
	kD2089_BUCK3_MAXV		= 0x0164,
	kD2089_BUCK3_OFS_V		= 0x0165,
	kD2089_BUCK3_MODE		= 0x0166,
	kD2089_BUCK3_START_ILIMIT	= 0x0167,
	kD2089_BUCK3_SYNC_ILIMIT	= 0x0168,
	kD2089_BUCK3_SLEEP_ILIMIT	= 0x0169,
	kD2089_BUCK3_FSM_TRIM0		= 0x016a,
	kD2089_BUCK3_FSM_TRIM2		= 0x016c,
	kD2089_BUCK3_FSM_TRIM3		= 0x016d,
	kD2089_BUCK3_CLK_TRIM		= 0x016e,
	kD2089_BUCK3_CALIB_OFFSET_TRIM	= 0x016f,
	kD2089_BUCK3_CALIB0		= 0x0170,
	kD2089_BUCK3_ANA_TRIM0		= 0x0172,
	kD2089_BUCK3_ANA_TRIM1		= 0x0173,
	kD2089_BUCK3_ANA_TRIM2		= 0x0174,
	kD2089_BUCK3_ANA_TRIM3		= 0x0175,
	
	kD2089_BUCK4_VSEL		= 0x0180,
	kD2089_BUCK4_VSEL_ALT		= 0x0181,
	kD2089_BUCK4_VSEL_ACTUAL	= 0x0182,
	kD2089_BUCK4_MINV		= 0x0183,
	kD2089_BUCK4_MAXV		= 0x0184,
	kD2089_BUCK4_OFS_V		= 0x0185,
	kD2089_BUCK4_MODE		= 0x0186,
	kD2089_BUCK4_START_ILIMIT	= 0x0187,
	kD2089_BUCK4_SYNC_ILIMIT	= 0x0188,
	kD2089_BUCK4_SLEEP_ILIMIT	= 0x0189,
	kD2089_BUCK4_FSM_TRIM0		= 0x018a,
	kD2089_BUCK4_FSM_TRIM2		= 0x018c,
	kD2089_BUCK4_FSM_TRIM3		= 0x018d,
	kD2089_BUCK4_CLK_TRIM		= 0x018e,
	kD2089_BUCK4_CALIB0		= 0x0190,
	kD2089_BUCK4_ANA_TRIM0		= 0x0192,
	kD2089_BUCK4_ANA_TRIM1		= 0x0193,
	kD2089_BUCK4_ANA_TRIM2		= 0x0194,
	kD2089_BUCK4_ANA_TRIM3		= 0x0195,
	
	kD2089_BUCK5_VSEL		= 0x01a0,
	kD2089_BUCK5_VSEL_ACTUAL	= 0x01a2,
	kD2089_BUCK5_MINV		= 0x01a3,
	kD2089_BUCK5_MAXV		= 0x01a4,
	kD2089_BUCK5_OFS_V		= 0x01a5,
	kD2089_BUCK5_MODE		= 0x01a6,
	kD2089_BUCK5_START_ILIMIT	= 0x01a7,
	kD2089_BUCK5_SYNC_ILIMIT	= 0x01a8,
	kD2089_BUCK5_SLEEP_ILIMIT	= 0x01a9,
	kD2089_BUCK5_FSM_TRIM0		= 0x01aa,
	kD2089_BUCK5_FSM_TRIM2		= 0x01ac,
	kD2089_BUCK5_FSM_TRIM3		= 0x01ad,
	kD2089_BUCK5_CLK_TRIM		= 0x01ae,
	kD2089_BUCK5_CALIB_OFFSET_TRIM	= 0x01af,
	kD2089_BUCK5_CALIB0		= 0x01b0,
	kD2089_BUCK5_ANA_TRIM0		= 0x01b2,
	kD2089_BUCK5_ANA_TRIM1		= 0x01b3,
	kD2089_BUCK5_ANA_TRIM2		= 0x01b4,
	kD2089_BUCK5_ANA_TRIM3		= 0x01b5,
	
	kD2089_BUCK6_VSEL		= 0x01c0,
	kD2089_BUCK6_VSEL_ACTUAL	= 0x01c2,
	kD2089_BUCK6_MINV		= 0x01c3,
	kD2089_BUCK6_MAXV		= 0x01c4,
	kD2089_BUCK6_OFS_V		= 0x01c5,
	kD2089_BUCK6_MODE		= 0x01c6,
	kD2089_BUCK6_ILIMIT	= 0x01c7,

	kD2089_BUCK6_FSM_TRIM0		= 0x01c8,
	kD2089_BUCK6_FSM_TRIM1		= 0x01c9,
	kD2089_BUCK6_FSM_TRIM2		= 0x01ca,
	kD2089_BUCK6_FSM_TRIM3		= 0x01cb,
	kD2089_BUCK6_CLK_TRIM		= 0x01cc,
	kD2089_BUCK6_CALIB_OFFSET_TRIM	= 0x01cd,
	kD2089_BUCK6_CALIB0		= 0x01ce,
	kD2089_BUCK6_ANA_TRIM0		= 0x01d0,
	kD2089_BUCK6_ANA_TRIM1		= 0x01d1,
	kD2089_BUCK6_ANA_TRIM2		= 0x01d2,

// LDO Control
	
	kD2089_LDO_RTC_TRIM		= 0x0304,
	kD2089_LDO1_VSEL		= 0x0308,
	kD2089_LDO1_VSEL_ACTUAL	= 0x0309,
	kD2089_LDO1_MINV		= 0x030a,
	kD2089_LDO1_MAXV		= 0x030b,
	kD2089_LDO2_VSEL		= 0x0310,
	kD2089_LDO2_VSEL_ACTUAL	= 0x0311,
	kD2089_LDO2_MINV		= 0x0312,
	kD2089_LDO2_MAXV		= 0x0313,
	kD2089_LDO3_VSEL		= 0x0318,
	kD2089_LDO3_VSEL_ACTUAL	= 0x0319,
	kD2089_LDO3_MINV		= 0x031a,
	kD2089_LDO3_MAXV		= 0x031b,
	kD2089_LDO4_VSEL		= 0x0320,
	kD2089_LDO4_VSEL_ACTUAL	= 0x0321,
	kD2089_LDO4_MINV		= 0x0322,
	kD2089_LDO4_MAXV		= 0x0323,
	kD2089_LDO5_VSEL		= 0x0328,
	kD2089_LDO5_VSEL_ACTUAL	= 0x0329,
	kD2089_LDO5_MINV		= 0x032a,
	kD2089_LDO5_MAXV		= 0x032b,
	kD2089_LDO5_TRIM		= 0x032c,
	kD2089_LDO6_VSEL		= 0x0330,
	kD2089_LDO6_VSEL_ACTUAL	= 0x0331,
	kD2089_LDO6_MINV		= 0x0332,
	kD2089_LDO6_MAXV		= 0x0333,
	kD2089_LDO6_TRIM		= 0x0334,
	kD2089_LDO7_VSEL		= 0x0338,
	kD2089_LDO7_VSEL_ACTUAL	= 0x0339,
	kD2089_LDO7_MINV		= 0x033a,
	kD2089_LDO7_MAXV		= 0x033b,
	kD2089_LDO8_VSEL		= 0x0340,
	kD2089_LDO8_VSEL_ACTUAL	= 0x0341,
	kD2089_LDO8_MINV		= 0x0342,
	kD2089_LDO8_MAXV		= 0x0343,
	kD2089_LDO9_VSEL		= 0x0348,
	kD2089_LDO9_VSEL_ACTUAL	= 0x0349,
	kD2089_LDO9_MINV		= 0x034a,
	kD2089_LDO9_MAXV		= 0x034b,
	kD2089_LDO10_VSEL		= 0x0350,
	kD2089_LDO10_VSEL_ACTUAL = 0x0351,
	kD2089_LDO10_MINV		= 0x0352,
	kD2089_LDO10_MAXV		= 0x0353,
	kD2089_LDO11_VSEL		= 0x0358,
	kD2089_LDO11_VSEL_ACTUAL = 0x0359,
	kD2089_LDO11_MINV		= 0x035a,
	kD2089_LDO11_MAXV		= 0x035b,
	kD2089_LDO13_VSEL		= 0x0368,
	kD2089_LDO13_VSEL_ACTUAL = 0x0369,
	kD2089_LDO13_MINV		= 0x036a,
	kD2089_LDO13_MAXV		= 0x036b,
	kD2089_LCM_LDO1			= 0x0370,
	kD2089_LCM_LDO1_VSEL_ACTUAL = 0x0371,
	kD2089_LCM_LDO1_MINV	= 0x0372,
	kD2089_LCM_LDO1_MAXV	= 0x0373,
	kD2089_LCM_LDO1_TRIM	= 0x0374,
	kD2089_LCM_LDO2			= 0x0378,
	kD2089_LCM_LDO2_VSEL_ACTUAL = 0x0379,
	kD2089_LCM_LDO2_MINV	= 0x037a,
	kD2089_LCM_LDO2_MAXV	= 0x037b,
	kD2089_LCM_LDO3			= 0x0380,
	kD2089_LCM_LDO3_VSEL_ACTUAL = 0x0381,
	kD2089_LCM_LDO3_MINV	= 0x0382,
	kD2089_LCM_LDO3_MAXV	= 0x0383,
	kD2089_LDO_BYP1			= 0x0388,
	kDIALOG_LDO_CONTROL		= kD2089_LDO_BYP1,

//	LCM Boost Control

	kD2089_LCM_BOOST_VSEL		=	0x0398,
	kD2089_LCM_BOOST_VSEL_ACTUAL =	0x0399,
	kD2089_LCM_BOOST_MINV		=	0x039a,
	kD2089_LCM_BOOST_MAXV		=	0x039b,
	kD2089_LCM_BOOST_CONF		=	0x039c,
	kD2089_LCM_BOOST_TRIM		=	0x039d,

//	Hibernate Switches

	kD2089_HIB_SW_CTRL		= 0x03c0,
	kD2089_HIB_SW_CTRL_2	= 0x03c1,

//	GPIO Control

	kD2089_GPIO1			= 0x0400,
	kDIALOG_SYS_GPIO_REG_START	= kD2089_GPIO1,
	kD2089_GPIO2			= 0x0401,
	kD2089_GPIO3			= 0x0402,
	kD2089_GPIO4			= 0x0403,
	kD2089_GPIO5			= 0x0404,
	kD2089_GPIO6			= 0x0405,
	kD2089_GPIO7			= 0x0406,
	kD2089_GPIO8			= 0x0407,
	kD2089_GPIO9			= 0x0408,
	kD2089_GPIO10			= 0x0409,
	kD2089_GPIO11			= 0x040a,
	kD2089_GPIO12			= 0x040b,
	kD2089_GPIO13			= 0x040c,
	kD2089_GPIO14			= 0x040d,
	kD2089_GPIO15			= 0x040e,
	kD2089_GPIO16			= 0x040f,
	kD2089_GPIO17			= 0x0410,

	kD2089_GPIO_DEB1		= 0x0420,
	kD2089_GPIO_DEB2		= 0x0421,
	kD2089_GPIO_DEB3		= 0x0422,
	kD2089_GPIO_DEB4		= 0x0423,
	kD2089_GPIO_DEB5		= 0x0424,
	kD2089_GPIO_DEB6		= 0x0425,
	kD2089_GPIO_DEB7		= 0x0426,
	kD2089_GPIO_DEB8		= 0x0427,
	kD2089_GPIO_DEB9		= 0x0428,

	kD2089_OUT_32K			= 0x0430,

//	GPI Control
	
	kD2089_BUTTON1_CONF		= 0x0440,
	kD2089_BUTTON2_CONF		= 0x0441,
	kD2089_BUTTON3_CONF		= 0x0442,
	kD2089_BUTTON4_CONF		= 0x0443,
	kDIALOG_BUTTON_DBL		= 0x0444,
	kD2089_BUTTON_WAKE		= 0x0445,
	
	kD2089_RESET_IN1_CONF		= 0x0448,
	kD2089_RESET_IN2_CONF		= 0x0449,
	kD2089_RESET_IN3_CONF		= 0x044a,
		kD2089_RIN_POL_RISE	= (0<<4),
		kD2089_RIN_POL_FALL	= (1<<4),
		kD2089_RIN_NO_PUPD	= (0<<2),
		kD2089_RIN_PU		= (1<<2),
		kD2089_RIN_PD		= (2<<2),
		kD2089_RIN_T_DEB_10MS	= (0<<1),
		kD2089_RIN_T_DEB_100MS	= (1<<1),
		kD2089_RIN_ENABLED	= (0<<0),
		kD2089_RIN_DISABLED	= (1<<0),

//	Temperature Sensor Control

	kD2089_TDEV1_RISE		= 0x0480,
	kD2089_TDEV1_FALL		= 0x0481,
	kD2089_TDEV2_RISE		= 0x0482,
	kD2089_TDEV2_FALL		= 0x0483,
	kD2089_TDEV3_RISE		= 0x0484,
	kD2089_TDEV3_FALL		= 0x0485,
	kD2089_TDEV4_RISE		= 0x0486,
	kD2089_TDEV4_FALL		= 0x0487,
	kD2089_TDEV5_RISE		= 0x0488,
	kD2089_TDEV5_FALL		= 0x0489,
	kD2089_TDEV6_RISE		= 0x048a,
	kD2089_TDEV6_FALL		= 0x048b,
	kD2089_TDEV7_RISE		= 0x048c,
	kD2089_TDEV7_FALL		= 0x048d,
	kD2089_TDEV8_RISE		= 0x048e,
	kD2089_TDEV8_FALL		= 0x048f,
	kD2089_TLDO5_RISE		= 0x04a0,
	kD2089_TCBUCK_A_RISE	= 0x04a2,
	kD2089_TCBUCK_B_RISE	= 0x04a3,
	kD2089_TLINCHG_RISE		= 0x04a4,
	kD2089_TBUCK0_RISE		= 0x04a5,
	kD2089_TBUCK1_RISE		= 0x04a6,
	kD2089_TBUCK52_RISE		= 0x04a7,
	kD2089_TBUCK34_RISE		= 0x04a8,
	kD2089_TBUCK06_RISE		= 0x04a9,
	kD2089_TISENSE_HYST		= 0x04aa,
	kDIALOG_T_OFFSET_MSB	= 0x04ab,
	kDIALOG_T_OFFSET_LSB	= 0x04ac,

//	Charging Control
	
	kD2089_ISET_BUCK		= 0x04c0,
	kD2089_ISET_BUCK_SHADOW		= 0x04c1,
	kD2089_ISET_BUCK_ABSMAX		= 0x04c2,
	kD2089_ISET_BUCK_ACTUAL		= 0x04c3,
	kD2089_ISET_BUCK_ALT		= 0x04c4,
	kDIALOG_CHARGE_BUCK_CONTROL	= kD2089_ISET_BUCK,
	kDIALOG_CHARGE_BUCK_STATUS	= kD2089_ISET_BUCK_ACTUAL,
	kD2089_CHG_CTRL_A		= 0x04c5,
	kD2089_CHG_CTRL_B		= 0x04c6,
	kD2089_CHG_CTRL_C		= 0x04c7,
	kD2089_CHG_CTRL_D		= 0x04c8,
	kD2089_CHG_CTRL_E		= 0x04c9,
	kD2089_CHG_CTRL_F		= 0x04ca,
	kD2089_CHG_CTRL_G		= 0x04cb,
	kD2089_CHG_TIME			= 0x04cc,
	kD2089_CHG_TIME_PRE		= 0x04cd,
	kDIALOG_CHARGE_CONTROL_ICHG_BAT = kD2089_CHG_CTRL_B,
	kDIALOG_CHARGE_CONTROL_HIB	= kD2089_CHG_CTRL_B,
	kDIALOG_CHARGE_CONTROL_TIME	= kD2089_CHG_CTRL_D,
	kDIALOG_CHARGE_CONTROL_EN	= kD2089_CHG_CTRL_A,
	kDIALOG_OTP_ISET_BAT		= kD2089_CHG_CTRL_C,
	kDIALOG_CHARGE_STATUS	= 0x04ce,
	kD2089_CHG_VSET_TRIM	= 0x04cf,
	kD2089_IBUS_GAIN_TRIM	= 0x04d1,
	kD2089_IBUS100_OFS_TRIM	= 0x04d2,
	kD2089_IBUS500_OFS_TRIM	= 0x04d3,
	kD2089_IBUS1500_GAIN_TRIM= 0x04d4,
	kD2089_IBUS1500_OFS_TRIM= 0x04d5,
	
	kD2089_CHG_TRIM1		= 0x04d6,
	kD2089_CHG_TRIM2		= 0x04d7,
	kD2089_CHG_TRIM3		= 0x04d8,
	kD2089_CHG_TRIM4		= 0x04d9,
	kD2089_CHG_TRIM5		= 0x04da,
	kD2089_ICHG_END			= 0x04db,

	kDIALOG_TBAT_0			= 0x04dc,
	kDIALOG_TBAT_1			= 0x04dd,
	kDIALOG_TBAT_2			= 0x04de,
	kDIALOG_TBAT_3			= 0x04df,
	kDIALOG_TBAT_4			= 0x04e0,
	kDIALOG_TBAT_MAX		= 0x04e1,
	kDIALOG_ICHG_TBAT_0		= 0x04e2,
	kDIALOG_ICHG_TBAT_1		= 0x04e3,
	kDIALOG_ICHG_TBAT_2		= 0x04e4,
	kDIALOG_ICHG_TBAT_3		= 0x04e5,
	kDIALOG_ICHG_TBAT_4		= 0x04e6,
	kDIALOG_ICHG_AVG		= 0x04e7,

// GPADC Control and Results

	kDIALOG_ADC_CONTROL		= 0x0500,
	kDIALOG_ADC_CONTROL2	= 0x0501,
	kDIALOG_ADC_LSB			= 0x0502,
	kDIALOG_ADC_MSB			= 0x0503,
	kD2089_ADC_TEMP_CTRL0	= 0x0504,
	kD2089_ADC_TEMP_CTRL1	= 0x0505,
	kD2089_ADC_FSM_TRIM0	= 0x0506,
	kD2089_ADC_FSM_TRIM1	= 0x0507,
	kD2089_ADC_FSM_TRIM2	= 0x0508,
	kD2089_ADC_FSM_TRIM3	= 0x0509,
	kD2089_ADC_ANA_TRIM0	= 0x050a,
	kD2089_VCC_MAIN_MON		= 0x050c,
	kDIALOG_IBUS_ACCUM1		= 0x050e,
	kDIALOG_IBUS_ACCUM2		= 0x050f,
	kDIALOG_IBUS_ACCUM3		= 0x0510,
	kDIALOG_VBUS_ACCUM1		= 0x0511,
	kDIALOG_VBUS_ACCUM2		= 0x0512,
	kDIALOG_VBUS_ACCUM3		= 0x0513,
	kDIALOG_TDIE_ACCUM1		= 0x0514,
	kDIALOG_TDIE_ACCUM2		= 0x0515,
	kDIALOG_TDIE_ACCUM3		= 0x0516,
	kDIALOG_IBUS_COUNT1		= 0x0517,
	kDIALOG_IBUS_COUNT2		= 0x0518,
	kD2089_IBUSCAL_1		= 0x0519,
	kD2089_IBUSCAL_2		= 0x051a,
	kD2089_IBUSCAL_3		= 0x051b,
	kD2089_IBUSCAL_4		= 0x051c,
	kD2089_IBUSCAL_5		= 0x051d,
	kD2089_IBUSCAL_6		= 0x051e,
	kD2089_IBUSCAL_7		= 0x051f,
	kD2089_IBUSCAL_8		= 0x0520,
	kD2089_IBUCK0_ACCUM1	= 0x0522,
	kD2089_IBUCK0_ACCUM2	= 0x0523,
	kD2089_IBUCK0_ACCUM3	= 0x0524,
	kD2089_IBUCK1_ACCUM1	= 0x0525,
	kD2089_IBUCK1_ACCUM2	= 0x0526,
	kD2089_IBUCK1_ACCUM3	= 0x0527,
	kDIALOG_IBUCK0_COUNT1	= 0x0528,
	kDIALOG_IBUCK0_COUNT2	= 0x0529,
	kDIALOG_IBUCK1_COUNT1	= 0x052a,
	kDIALOG_IBUCK1_COUNT2	= 0x052b,

//	BIST ADC Control and Results

	kDIALOG_APP_TMUX		= 0x0540,
	kDIALOG_BIST_ADC_CTRL		= 0x0541,
	kDIALOG_BIST_ADC_LSB		= 0x0542,
	kDIALOG_BIST_ADC_MSB		= 0x0543,
	kD2089_BIST_ADC_TRIM1		= 0x0545,
	kD2089_BIST_ADC_ANA_TRIM0	= 0x0546,

//	RTC Calendar and Alarm
	
	kDIALOG_RTC_ALARM_A		= 0x05c0,
	kDIALOG_RTC_ALARM_B		= 0x05c1,
	kDIALOG_RTC_ALARM_C		= 0x05c2,
	kDIALOG_RTC_ALARM_D		= 0x05c3,
	kDIALOG_RTC_CONTROL		= 0x05c4,
	kDIALOG_RTC_TIMEZONE		= 0x05c5,
	kDIALOG_RTC_SUB_SECOND_A	= 0x05c6,
	kDIALOG_RTC_SUB_SECOND_B	= 0x05c7,
	kDIALOG_RTC_SECOND_A		= 0x05c8,
	kDIALOG_RTC_SECOND_B		= 0x05c9,
	kDIALOG_RTC_SECOND_C		= 0x05ca,
	kDIALOG_RTC_SECOND_D		= 0x05cb,

//	WLED

	kD2089_WLED_ISET_MSB	= 0x0600,
	kD2089_WLED_ISET_LSB	= 0x0601,
	kD2089_WLED_PWM_MSB		= 0x0602,
	kD2089_WLED_PWM_LSB		= 0x0603,
	kD2089_WLED_CTRL1		= 0x0604,
	kD2089_WLED_CTRL2		= 0x0605,
	kD2089_WLED_CTRL3		= 0x0606,
	kD2089_WLED_CTRL4		= 0x0607,
	kD2089_WLED_CTRL5		= 0x0608,
	kD2089_WLED_CTRL6		= 0x0609,
	kD2089_WLED_CTRL7		= 0x060a,
	kD2089_WLED_ERR_STAT_A	= 0x060b,
	kD2089_WLED_ERR_STAT_B	= 0x060c,
	kD2089_WLED_CONF1		= 0x060d,
	kD2089_WLED_CONF2		= 0x060e,
	kD2089_WLED_CONF3		= 0x060f,
	kD2089_WLED_TRIM1		= 0x0610,
	kD2089_WLED_TRIM2		= 0x0611,
	kD2089_WLED_TRIM3		= 0x0612,
	kD2089_WLED_TRIM4		= 0x0613,
	kD2089_WLED_TRIM5		= 0x0614,
	kD2089_WLED_TRIM6		= 0x0615,
	kD2089_WLED_TRIM7		= 0x0616,
	kD2089_WLED_TRIM8		= 0x0617,
	kD2089_WLED_TRIM9		= 0x0618,
	kD2089_WLED_TRIM10		= 0x0619,
	kD2089_WLED_TRIM11		= 0x061a,
	kD2089_WLED_TRIM12		= 0x061b,
	kD2089_WLED_TRIM13		= 0x061c,
	kD2089_WLED_TRIM14		= 0x061d,
	kD2089_WLED_TRIM15		= 0x061e,
	kD2089_WLED_TRIM16		= 0x061f,
	kD2089_WLED_TRIM17		= 0x0620,
	kD2089_WLED_TRIM18		= 0x0621,
	kD2089_WLED_TRIM19		= 0x0622,
	kD2089_WLED_TRIM20		= 0x0623,

    kDIALOG_WLED_ISET       = kD2089_WLED_ISET_MSB,
    kDIALOG_WLED_ISET2      = kD2089_WLED_ISET_LSB,
    kDIALOG_WLED_CONTROL	= kD2089_WLED_CTRL1,
    kDIALOG_WLED_DWI_CONTROL= kD2089_WLED_CTRL2,
    kDIALOG_WLED_OPTIONS	= kD2089_WLED_CTRL2,

//	Reserved Spare Registers

	kD2089_SPARE_RW0		= 0x0680,
	kD2089_SPARE_RW_LAST	= 0x0687,
	kD2089_SPARE_RWTOTP0	= 0x06a0,
	kD2089_SPARE_RWTOTP_LAST= 0x06a7,
	kD2089_SPARE_RWOTP0		= 0x06c0,
	kD2089_SPARE_RWOTP1		= 0x0610,

//	Legacy Scratch Pads

	kDIALOG_MEMBYTE0		= 0x4000,
	kDIALOG_MEMBYTE_LAST	= 0x4027,

//	Scratch Pad RAM

	kDIALOG_RAM0			= 0x8000,
		kDIALOG_EXT_MEM_CAL0 = kDIALOG_RAM0,
			kDIALOG_EXT_MEM_CAL0_SIZE = 64,
		kDIALOG_DIAG_SCRATCH	= kDIALOG_EXT_MEM_CAL0+kDIALOG_EXT_MEM_CAL0_SIZE,	// <rdar://problem/13485884>
			kDIALOG_DIAG_SCRATCH_SIZE = 8,
		kDIALOG_EXT_MEM_CAL1= kDIALOG_DIAG_SCRATCH+kDIALOG_DIAG_SCRATCH_SIZE,
			kDIALOG_EXT_MEM_CAL1_SIZE= 336,
		kDIALOG_VOLTAGE_KNOBS = kDIALOG_EXT_MEM_CAL1+kDIALOG_EXT_MEM_CAL1_SIZE,
			kDIALOG_VOLTAGE_KNOBS_SIZE=32,

		kDIALOG_EXT_MEM_CAL_SIZE= kDIALOG_EXT_MEM_CAL0_SIZE+kDIALOG_EXT_MEM_CAL1_SIZE,

	kDIALOG_RAM_LAST		= 0x87ff,
};


// Synthetic Accumulator Registers 
enum {
    kDIALOG_ACCUMULATOR_SEL_COUNT   = 4,
	kDIALOG_IBUS_ACCUMULATOR	= 0,
	kDIALOG_VBUS_ACCUMULATOR	= 1,
	kDIALOG_IBUCK0_ACCUMULATOR	= 2,
	kDIALOG_IBUCK1_ACCUMULATOR	= 3,
};

enum {
	kD2089_EVENT_A_TBAT		= (1 << 7),
	kD2089_EVENT_A_VBUS_EXT_REM	= (1 << 6),
	kD2089_EVENT_A_VDD_LOW		= (1 << 5),
	kD2089_EVENT_A_CHG_HV_ATT	= (1 << 4),
	kD2089_EVENT_A_VBUS_EXT_DET	= (1 << 3),
	kD2089_EVENT_A_ACC_DET		= (1 << 2),
	kD2089_EVENT_A_VCENTER_DET	= (1 << 0),
};

enum {
	kD2089_EVENT_B_BTN4_DBL		= (1 << 7),
	kD2089_EVENT_B_BTN3_DBL		= (1 << 6),
	kD2089_EVENT_B_BTN2_DBL		= (1 << 5),
	kD2089_EVENT_B_BTN1_DBL		= (1 << 4),
	kD2089_EVENT_B_BUTTON_4		= (1 << 3),
	kD2089_EVENT_B_BUTTON_3		= (1 << 2),
	kD2089_EVENT_B_BUTTON_2		= (1 << 1),
	kD2089_EVENT_B_BUTTON_1		= (1 << 0),
};

enum {
	kD2089_EVENT_C_CHG_BUCK_FLG	= (1 << 6),
	kD2089_EVENT_C_CHG_ABCC_ACT	= (1 << 5),
	kD2089_EVENT_C_CHG_TIMEOUT	= (1 << 4),
	kD2089_EVENT_C_CHG_PRECHG_TIMEOUT	= (1 << 3),
	kD2089_EVENT_C_CHG_END		= (1 << 2),
	kD2089_EVENT_C_CHG_FAST		= (1 << 1),
	kD2089_EVENT_C_CHG_PRE		= (1 << 0),
};

enum {
	kD2089_EVENT_D_GPIO8		= (1 << 7),
	kD2089_EVENT_D_GPIO7		= (1 << 6),
	kD2089_EVENT_D_GPIO6		= (1 << 5),
	kD2089_EVENT_D_GPIO5		= (1 << 4),
	kD2089_EVENT_D_GPIO4		= (1 << 3),
	kD2089_EVENT_D_GPIO3		= (1 << 2),
	kD2089_EVENT_D_GPIO2		= (1 << 1),
	kD2089_EVENT_D_GPIO1		= (1 << 0),
};

enum {
	kD2089_EVENT_E_GPIO16		= (1 << 7),
	kD2089_EVENT_E_GPIO15		= (1 << 6),
	kD2089_EVENT_E_GPIO14		= (1 << 5),
	kD2089_EVENT_E_GPIO13		= (1 << 4),
	kD2089_EVENT_E_GPIO12		= (1 << 3),
	kD2089_EVENT_E_GPIO11		= (1 << 2),
	kD2089_EVENT_E_GPIO10		= (1 << 1),
	kD2089_EVENT_E_GPIO9		= (1 << 0),
};

enum {
	kD2089_EVENT_F_GPIO17		= (1 << 0),
};

enum {
	kD2089_EVENT_G_T4_RISE		= (1 << 7),
	kD2089_EVENT_G_T4_FALL		= (1 << 6),
	kD2089_EVENT_G_T3_RISE		= (1 << 5),
	kD2089_EVENT_G_T3_FALL		= (1 << 4),
	kD2089_EVENT_G_T2_RISE		= (1 << 3),
	kD2089_EVENT_G_T2_FALL		= (1 << 2),
	kD2089_EVENT_G_T1_RISE		= (1 << 1),
	kD2089_EVENT_G_T1_FALL		= (1 << 0),
};

enum {
	kD2089_EVENT_H_T8_RISE		= (1 << 7),
	kD2089_EVENT_H_T8_FALL		= (1 << 6),
	kD2089_EVENT_H_T7_RISE		= (1 << 5),
	kD2089_EVENT_H_T7_FALL		= (1 << 4),
	kD2089_EVENT_H_T6_RISE		= (1 << 3),
	kD2089_EVENT_H_T6_FALL		= (1 << 2),
	kD2089_EVENT_H_T5_RISE		= (1 << 1),
	kD2089_EVENT_H_T5_FALL		= (1 << 0),
};

enum {
	kD2089_EVENT_I_TLDO5		= (1 << 7),
	kD2089_EVENT_I_TBUCK_0_6	= (1 << 4),
	kD2089_EVENT_I_TBUCK_3_4	= (1 << 3),
	kD2089_EVENT_I_TBUCK_5_2	= (1 << 2),
	kD2089_EVENT_I_TBUCK1		= (1 << 1),
	kD2089_EVENT_I_TBUCK0		= (1 << 0),
};

enum {
	kD2089_EVENT_J_HIGH_TEMP_WARNING	= (1 << 7),
	kD2089_EVENT_J_WLEDB_SHORT	= (1 << 6),
	kD2089_EVENT_J_WLEDB_OPEN	= (1 << 5),
	kD2089_EVENT_J_WLEDA_SHORT	= (1 << 4),
	kD2089_EVENT_J_WLEDA_OPEN	= (1 << 3),
	kD2089_EVENT_J_TLINCHG		= (1 << 2),
	kD2089_EVENT_J_TCBUCK_B		= (1 << 1),
	kD2089_EVENT_J_TCBUCK_A		= (1 << 0),
};

enum {
	kD2089_EVENT_K_XTAL_ERROR 	= (1 << 6),
	kD2089_EVENT_K_VBUS_OV		= (1 << 5),
	kD2089_EVENT_K_VBUS_OC		= (1 << 4),
	kD2089_EVENT_K_LDO6_OC		= (1 << 0),
};

enum {
	kD2089_EVENT_L_IBUCK1_OVERFLOW	= (1 << 7),
	kD2089_EVENT_L_IBUCK0_OVERFLOW	= (1 << 6),
	kD2089_EVENT_L_IBUS_OVERFLOW	= (1 << 5),
	kD2089_EVENT_L_HIB			= (1 << 4),
	kD2089_EVENT_L_DWI_TO		= (1 << 3),
	kD2089_EVENT_L_EOMC_BIST	= (1 << 2),
	kD2089_EVENT_L_EOMC			= (1 << 1),
	kD2089_EVENT_L_ALARM		= (1 << 0),
};

enum {
	kD2089_EVENT_M_BUCK2_POS_ILIM_MON	= (1 << 7),
	kD2089_EVENT_M_BUCK2_NEG_ILIM_MON	= (1 << 6),
	kD2089_EVENT_M_BUCK1_POS_ILIM_MON	= (1 << 5),
	kD2089_EVENT_M_BUCK1_NEG_ILIM_MON	= (1 << 4),
	kD2089_EVENT_M_BUCK0_POS_ILIM_MON	= (1 << 3),
	kD2089_EVENT_M_BUCK0_NEG_ILIM_MON	= (1 << 2),
};

enum {
	kD2089_EVENT_N_BUCK6_POS_ILIM_MON	= (1 << 7),
	kD2089_EVENT_N_BUCK6_NEG_ILIM_MON	= (1 << 6),
	kD2089_EVENT_N_BUCK5_POS_ILIM_MON	= (1 << 5),
	kD2089_EVENT_N_BUCK5_NEG_ILIM_MON	= (1 << 4),
	kD2089_EVENT_N_BUCK4_POS_ILIM_MON	= (1 << 3),
	kD2089_EVENT_N_BUCK4_NEG_ILIM_MON	= (1 << 2),
	kD2089_EVENT_N_BUCK3_POS_ILIM_MON	= (1 << 1),
	kD2089_EVENT_N_BUCK3_NEG_ILIM_MON	= (1 << 0),
};

enum {
	kD2089_STATUS_A_TBAT		= (1 << 7),
	kD2089_STATUS_A_VDD_LOW		= (1 << 5),
	kD2089_STATUS_A_CHG_HV_ATT	= (1 << 4),
	kD2089_STATUS_A_VBUS_EXT_DET= (1 << 3),
	kD2089_STATUS_A_ACC_DET		= (1 << 2),
	kD2089_STATUS_A_VCENTER_DET	= (1 << 0),
};

enum {
	kD2089_STATUS_B_BUTTON_4	= (1 << 3),
	kD2089_STATUS_B_BUTTON_3	= (1 << 2),
	kD2089_STATUS_B_BUTTON_2	= (1 << 1),
	kD2089_STATUS_B_BUTTON_1	= (1 << 0),
};

enum {
	kD2089_STATUS_C_CHG_HV_EN	= (1 << 7),
	kD2089_STATUS_C_CHG_BUCK_FLG= (1 << 6),
	kD2089_STATUS_C_CHG_ABCC_ACT= (1 << 5),
	kD2089_STATUS_C_CHG_TIMEOUT	= (1 << 4),
	kD2089_STATUS_C_CHG_PRECHG_TIMEOUT	= (1 << 3),
	kD2089_STATUS_C_CHG_END		= (1 << 2),
	kD2089_STATUS_C_CHG_FAST	= (1 << 1),
	kD2089_STATUS_C_CHG_PRE		= (1 << 0),
};

enum {
	kD2089_STATUS_D_GPIO8		= (1 << 7),
	kD2089_STATUS_D_GPIO7		= (1 << 6),
	kD2089_STATUS_D_GPIO6		= (1 << 5),
	kD2089_STATUS_D_GPIO5		= (1 << 4),
	kD2089_STATUS_D_GPIO4		= (1 << 3),
	kD2089_STATUS_D_GPIO3		= (1 << 2),
	kD2089_STATUS_D_GPIO2		= (1 << 1),
	kD2089_STATUS_D_GPIO1		= (1 << 0),
};

enum {
	kD2089_STATUS_E_GPIO16		= (1 << 7),
	kD2089_STATUS_E_GPIO15		= (1 << 6),
	kD2089_STATUS_E_GPIO14		= (1 << 5),
	kD2089_STATUS_E_GPIO13		= (1 << 4),
	kD2089_STATUS_E_GPIO12		= (1 << 3),
	kD2089_STATUS_E_GPIO11		= (1 << 2),
	kD2089_STATUS_E_GPIO10		= (1 << 1),
	kD2089_STATUS_E_GPIO9		= (1 << 0),
};

enum {
	kD2089_STATUS_F_GPIO17		= (1 << 0),
};

enum {
	kD2089_STATUS_G_T4_RISE		= (1 << 7),
	kD2089_STATUS_G_T4_FALL		= (1 << 6),
	kD2089_STATUS_G_T3_RISE		= (1 << 5),
	kD2089_STATUS_G_T3_FALL		= (1 << 4),
	kD2089_STATUS_G_T2_RISE		= (1 << 3),
	kD2089_STATUS_G_T2_FALL		= (1 << 2),
	kD2089_STATUS_G_T1_RISE		= (1 << 1),
	kD2089_STATUS_G_T1_FALL		= (1 << 0),
};

enum {
	kD2089_STATUS_H_T8_RISE		= (1 << 7),
	kD2089_STATUS_H_T8_FALL		= (1 << 6),
	kD2089_STATUS_H_T7_RISE		= (1 << 5),
	kD2089_STATUS_H_T7_FALL		= (1 << 4),
	kD2089_STATUS_H_T6_RISE		= (1 << 3),
	kD2089_STATUS_H_T6_FALL		= (1 << 2),
	kD2089_STATUS_H_T5_RISE		= (1 << 1),
	kD2089_STATUS_H_T5_FALL		= (1 << 0),
};

enum {
	kD2089_STATUS_I_TLDO5		= (1 << 7),
	kD2089_STATUS_I_TBUCK_0_6	= (1 << 4),
	kD2089_STATUS_I_TBUCK_3_4	= (1 << 3),
	kD2089_STATUS_I_TBUCK_5_2	= (1 << 2),
	kD2089_STATUS_I_TBUCK1		= (1 << 1),
	kD2089_STATUS_I_TBUCK0		= (1 << 0),
};

enum {
	kD2089_STATUS_J_HIGH_TEMP_WARNING	= (1 << 7),
	kD2089_STATUS_J_TLINCHG		= (1 << 2),
	kD2089_STATUS_J_TCBUCK_B	= (1 << 1),
	kD2089_STATUS_J_TCBUCK_A	= (1 << 0),
};

enum {
	kD2089_STATUS_K_XTAL_ERROR	= (1 << 6),
	kD2089_STATUS_K_VBUS_OV		= (1 << 5),
	kD2089_STATUS_K_VBUS_OC		= (1 << 4),
};

enum {
	kD2089_STATUS_L_IBUCK1_OVERFLOW	= (1 << 7),
	kD2089_STATUS_L_IBUCK0_OVERFLOW	= (1 << 6),
	kD2089_STATUS_L_IBUS_OVERFLOW	= (1 << 5),
};

enum {
	kD2089_STATUS_M_PROT_FET_ON	= (1 << 1),
	kD2089_STATUS_M_CHG_ATT		= (1 << 0),
};

enum {
	kDIALOG_EVENT_HOLD_BUTTON_MASK	= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BUTTON_2),
	kDIALOG_EVENT_MENU_BUTTON_MASK	= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BUTTON_1),
	kDIALOG_EVENT_RINGER_BUTTON_MASK= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BUTTON_3),
	kDIALOG_EVENT_BUTTON4_MASK= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BUTTON_4),
	kDIALOG_EVENT_BUTTONS		= (kD2089_EVENT_B_BUTTON_4 |
					   kD2089_EVENT_B_BUTTON_3 |
					   kD2089_EVENT_B_BUTTON_2 |
					   kD2089_EVENT_B_BUTTON_1),
	kDIALOG_EVENT_BUTTONS_MASK	= EVENT_FLAG_MAKE(1, kDIALOG_EVENT_BUTTONS),
	kDIALOG_EVENT_PWR_BUTTON_MASK	= kDIALOG_EVENT_HOLD_BUTTON_MASK,
	
	kDIALOG_EVENT_ALARM_MASK	= EVENT_FLAG_MAKE(11, kD2089_EVENT_L_ALARM),
	kDIALOG_EVENT_ACC_DET_MASK	= EVENT_FLAG_MAKE(0, kD2089_EVENT_A_ACC_DET),
	kDIALOG_EVENT_VBUS_DET_MASK	= EVENT_FLAG_MAKE(0, kD2089_EVENT_A_VBUS_EXT_DET),
	kDIALOG_EVENT_VBUS_EXT_REM_MASK	= EVENT_FLAG_MAKE(0, kD2089_EVENT_A_VBUS_EXT_REM),
	kDIALOG_EVENT_EOMC_MASK		= EVENT_FLAG_MAKE(11, kD2089_EVENT_L_EOMC),
	kDIALOG_EVENT_HIB_MASK		= EVENT_FLAG_MAKE(11, kD2089_EVENT_L_HIB),
	kDIALOG_EVENT_ABCC_MASK		= EVENT_FLAG_MAKE(2, kD2089_EVENT_C_CHG_ABCC_ACT),
	
	kDIALOG_EVENT_CHG_END_MASK	= EVENT_FLAG_MAKE(2, kD2089_EVENT_C_CHG_END),
	kDIALOG_EVENT_TBAT_MASK		= EVENT_FLAG_MAKE(0, kD2089_EVENT_A_TBAT),
	
	kDIALOG_EVENT_GPIO1_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO1),
	kDIALOG_EVENT_GPIO2_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO2),
	kDIALOG_EVENT_GPIO3_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO3),
	kDIALOG_EVENT_GPIO4_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO4),
	kDIALOG_EVENT_GPIO5_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO5),
	kDIALOG_EVENT_GPIO6_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO6),
	kDIALOG_EVENT_GPIO7_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO7),
	kDIALOG_EVENT_GPIO8_MASK	= EVENT_FLAG_MAKE(3, kD2089_EVENT_D_GPIO8),
	kDIALOG_EVENT_GPIO9_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO9),
	kDIALOG_EVENT_GPIO10_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO10),
	kDIALOG_EVENT_GPIO11_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO11),
	kDIALOG_EVENT_GPIO12_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO12),
	kDIALOG_EVENT_GPIO13_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO13),
	kDIALOG_EVENT_GPIO14_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO14),
	kDIALOG_EVENT_GPIO15_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO15),
	kDIALOG_EVENT_GPIO16_MASK	= EVENT_FLAG_MAKE(4, kD2089_EVENT_E_GPIO16),
	kDIALOG_EVENT_GPIO17_MASK	= EVENT_FLAG_MAKE(5, kD2089_EVENT_F_GPIO17),

	kDIALOG_EVENT_HOLD_DBL_MASK	= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BTN2_DBL),
	kDIALOG_EVENT_MENU_DBL_MASK	= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BTN1_DBL),
	kDIALOG_EVENT_RINGER_DBL_MASK	= EVENT_FLAG_MAKE(1, kD2089_EVENT_B_BTN3_DBL),

	kDIALOG_EVENT_VHP_DET_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_ON_MASK		= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_LDO2_EN_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO18_MASK	= kDIALOG_NOTEXIST_MASK,
};

// FIX ME
enum {
	kDIALOG_STATUS_USB_MASK		= STATUS_FLAG_MAKE(0, kD2089_STATUS_A_VCENTER_DET),
	kDIALOG_STATUS_VBUS_MASK	= STATUS_FLAG_MAKE(0, kD2089_STATUS_A_VBUS_EXT_DET),
	kDIALOG_STATUS_FW_MASK		= kDIALOG_NOTEXIST_MASK,
	kDIALOG_STATUS_ACC_DET_MASK	= STATUS_FLAG_MAKE(0, kD2089_STATUS_A_ACC_DET),
	kDIALOG_STATUS_CHARGING_MASK	= STATUS_FLAG_MAKE(3, kD2089_STATUS_C_CHG_PRE | kD2089_STATUS_C_CHG_FAST),
	kDIALOG_STATUS_CHG_TO_MASK	= STATUS_FLAG_MAKE(2, kD2089_STATUS_C_CHG_TIMEOUT),
	kDIALOG_STATUS_CHG_END_MASK	= STATUS_FLAG_MAKE(2, kD2089_STATUS_C_CHG_END),
	kDIALOG_STATUS_TBAT_MASK	= STATUS_FLAG_MAKE(0, kD2089_STATUS_A_TBAT),
	kDIALOG_STATUS_CHG_ATT_MASK     = STATUS_FLAG_MAKE(12, kD2089_STATUS_M_CHG_ATT),
	kDIALOG_STATUS_ABCC_MASK	= STATUS_FLAG_MAKE(2, kD2089_STATUS_C_CHG_ABCC_ACT),
#define	kDIALOG_STATUS_GPIO_MASK(gpio)	  STATUS_FLAG_MAKE(3 + ((gpio)/8), (1 << ((gpio) % 8)))
};

static const statusRegisters kDialogStatusFWMask = {0, 0, 0, 0, 0, 0};
static const statusRegisters kDialogStatusChargingMask = {0, 0, kD2089_STATUS_C_CHG_PRE | kD2089_STATUS_C_CHG_FAST };

enum {
	kD2089_EVENT_A_WAKEMASK = (kD2089_EVENT_A_VBUS_EXT_DET |
				   kD2089_EVENT_A_VCENTER_DET |
				   kD2089_EVENT_A_ACC_DET),
	kD2089_EVENT_B_WAKEMASK = (kD2089_EVENT_B_BUTTON_1 |
				   kD2089_EVENT_B_BUTTON_2 |
				   kD2089_EVENT_B_BUTTON_3 |
				   kD2089_EVENT_B_BUTTON_4),
	kD2089_EVENT_C_WAKEMASK = 0,
	kD2089_EVENT_D_WAKEMASK = 0,
	kD2089_EVENT_E_WAKEMASK = 0,
	kD2089_EVENT_F_WAKEMASK = 0,
	kD2089_EVENT_G_WAKEMASK = 0,
	kD2089_EVENT_H_WAKEMASK = 0,
	kD2089_EVENT_I_WAKEMASK = 0,
	kD2089_EVENT_J_WAKEMASK = 0,
	kD2089_EVENT_K_WAKEMASK = 0,
	kD2089_EVENT_L_WAKEMASK = kD2089_EVENT_L_ALARM,
};

// All events that are masked during shutdown - inverse of the wake mask,
// events that wake up the system
static const eventRegisters kDialogEventIntMasks = {
	~kD2089_EVENT_A_WAKEMASK,
	~kD2089_EVENT_B_WAKEMASK,
	~kD2089_EVENT_C_WAKEMASK,
	~kD2089_EVENT_D_WAKEMASK,
	~kD2089_EVENT_E_WAKEMASK,
	~kD2089_EVENT_F_WAKEMASK,
	~kD2089_EVENT_G_WAKEMASK,
	~kD2089_EVENT_H_WAKEMASK,
	~kD2089_EVENT_I_WAKEMASK,
	~kD2089_EVENT_J_WAKEMASK,
	~kD2089_EVENT_K_WAKEMASK,
	~kD2089_EVENT_L_WAKEMASK,
};


// All wake events without the buttons
static const eventRegisters kDialogEventNotButtonMasks = {
	kD2089_EVENT_A_WAKEMASK,
	kD2089_EVENT_B_WAKEMASK & ~kDIALOG_EVENT_BUTTONS,
	kD2089_EVENT_C_WAKEMASK,
	kD2089_EVENT_D_WAKEMASK,
	kD2089_EVENT_E_WAKEMASK,
	kD2089_EVENT_F_WAKEMASK,
	kD2089_EVENT_G_WAKEMASK,
	kD2089_EVENT_H_WAKEMASK,
	kD2089_EVENT_I_WAKEMASK,
	kD2089_EVENT_J_WAKEMASK,
	kD2089_EVENT_K_WAKEMASK,
	kD2089_EVENT_L_WAKEMASK,
};

// All events indicating external power supply
static const eventRegisters kDialogEventPwrsupplyMask = {
	kD2089_EVENT_A_VBUS_EXT_DET | kD2089_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
};

static const eventRegisters kDialogEventUSBMask = {
	// only include VCENTER_DET; VBUS can come and go while charger still usable
	kD2089_EVENT_A_VCENTER_DET,
	0,
	kD2089_EVENT_C_CHG_ABCC_ACT,
	0,
	0,
	0,
	0,
	0,
	0,
};

static const eventRegisters kDialogEventFWMask = {
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
};

enum {
	kDialogEventPwrsupplyCount = 2,
	kDialogEventUSBCount = 2,
	kDialogEventFWCount = 0,
};

enum {
	kDIALOG_LCM_ACTIVE_BOOST_EN		= (1 << 0) | (1 << 1),
	kDIALOG_LCM_ACTIVE_MASK			= (1 << 2) | (1 << 3) | (1 << 4),
};

enum {
	kDIALOG_SYS_CONTROL_STANDBY		= (1 << 0),
	kDIALOG_SYS_CONTROL_HIBERNATE		= (1 << 1),
	kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND	= (1 << 2),
	kDIALOG_SYS_CONTROL_HIB_CLK		= (1 << 4),
	kDIALOG_SYS_CONTROL_PROT_FET_DIS	= (1 << 5),
	kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND	= (1 << 6),
	kDIALOG_SYS_CONTROL_CHRG_CONTROLS	= kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND
						| kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND,
	kDIALOG_SYS_CONTROL_HIBERNATE_ALWAYS    = kDIALOG_SYS_CONTROL_HIBERNATE,
};

enum {
	kDIALOG_SYS_CONTROL2_DWI_EN		= (1 << 0),
	kDIALOG_SYS_CONTROL2_DWI_TEST_EN	= (1 << 1),
	kDIALOG_SYS_CONTROL2_HIB_32K		= (1 << 4),
};

enum {
	// FAULT_LOG1
	kDIALOG_FAULT_LOG_WDOG		= FAULTLOG_FLAG_MAKE(0, (1 << 7)),
	kDIALOG_FAULT_LOG_RESET_IN_3	= FAULTLOG_FLAG_MAKE(0, (1 << 6)),
	kDIALOG_FAULT_LOG_RESET_IN_2	= FAULTLOG_FLAG_MAKE(0, (1 << 5)),
	kDIALOG_FAULT_LOG_RESET_IN_1	= FAULTLOG_FLAG_MAKE(0, (1 << 4)),
	kDIALOG_FAULT_LOG_RST		= FAULTLOG_FLAG_MAKE(0, (1 << 3)),
	kDIALOG_FAULT_LOG_POR		= FAULTLOG_FLAG_MAKE(0, (1 << 2)),
	kDIALOG_FAULT_LOG_OVER_TEMP	= FAULTLOG_FLAG_MAKE(0, (1 << 1)),
	kDIALOG_FAULT_LOG_VDD_UNDER	= FAULTLOG_FLAG_MAKE(0, (1 << 0)),
	// FAULT_LOG2
	kDIALOG_FAULT_LOG_BTN_SHUTDOWN      = FAULTLOG_FLAG_MAKE(1, (1 << 2)),
	kDIALOG_FAULT_LOG_TWO_FINGER_RESET  = FAULTLOG_FLAG_MAKE(1, (1 << 1)),
	kDIALOG_FAULT_LOG_NTC_SHDN          = FAULTLOG_FLAG_MAKE(1, (1 << 0)),
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MIN  = 0x00,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_100  = 0x02,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_200  = 0x0a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_300  = 0x12,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_400  = 0x1a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_500  = 0x22,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_600  = 0x2a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_700  = 0x32,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_900  = 0x42,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_975  = 0x48,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1000 = 0x4a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1450 = 0x6e,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1500 = 0x72,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1900 = 0x92,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2000 = 0x9a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2100 = 0xa2,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2300 = 0xb2,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MAX  = 0xff,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MASK = 0xff,
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_MIN		   = 75,
	kDIALOG_CHARGE_BUCK_CONTROL_STEP_PER_100MA = 8,
	kDIALOG_CHARGE_BUCK_CONTROL_MAX		   = 3262,
};

enum {
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_MASK	 = 0x3f,
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT  = 0,
	kDIALOG_OTP_ISET_BAT_SHIFT		= kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT,
	kDIALOG_CHARGE_CONTROL_B_CHG_SUSP	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_B_CHG_HIB	= (1 << 7),
	kDIALOG_CHARGE_CONTROL_CHG_HIB		= kDIALOG_CHARGE_CONTROL_B_CHG_HIB,
};

enum {
	kDIALOG_CHARGE_CONTROL_STEP		= 50,
	kDIALOG_CHARGE_CONTROL_MAX		= 3150,
};

enum {
	kDIALOG_CHARGE_CONTROL_ALT_USB_DIS	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_CHG_BUCK_EN	= (1 << 7),
};

enum {
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_MASK	    = 0xF0,
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_DISABLED   = 0x00,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_MASK	    = 0x07,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_DISABLED   = 0x00,
};

enum {
	kDIALOG_ADC_LSB_ADC_OVL			= (1 << 7),
	kDIALOG_ADC_LSB_MANADC_ERROR		= (1 << 6),
};

enum {
	kDIALOG_ADC_CONTROL_MAN_CONV		= (1 << 7),
	kDIALOG_ADC_CONTROL_MUX_SEL_MASK	= (0x3f << 0),

	kDIALOG_ADC_CONTROL_MUX_SEL_VDD_OUT	= (0 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ICH		= (1 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TBAT	= (2 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ACC_ID	= (3 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VBAT	= (4 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_LG	= (5 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BRICK_ID= (6 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IN7	= (7 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TJUNC	= (8 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_HG	= (9 << 0),
		kDIALOG_ADC_CONTROL_MUX_SEL_VIBUS	= kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_HG,
	kDIALOG_ADC_CONTROL_MUX_SEL_NTC0	= (10 << 0),
		kDIALOG_ADC_CONTROL_MUX_NUM_NTC		= 9,
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS	= (19 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_LG_OFF	= (20 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_HG_OFF	= (21 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK52_TEMP	= (22 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_LDO5_TEMP	= (23 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_B_TEMP= (24 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CHG_TEMP = (25 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK0_TEMP	= (26 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK1_TEMP	= (27 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK0_6_TEMP = (28 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK3_4_TEMP = (29 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP= (30 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IN31	= (31 << 0),

		kDIALOG_ADC_CONTROL_MUX_SEL_TINT_START	= kDIALOG_ADC_CONTROL_MUX_SEL_BUCK52_TEMP,
		kDIALOG_ADC_CONTROL_MUX_SEL_TINT_END	= kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP,

	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK0	= (32 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK1	= (33 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK2	= (34 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK3	= (35 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK4	= (36 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK5	= (37 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK0_OFF	= (38 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK1_OFF	= (39 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK2_OFF	= (40 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK3_OFF	= (41 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK4_OFF	= (42 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IBUCK5_OFF	= (43 << 0),
	
	kDIALOG_ADC_CONTROL2_AUTO_VDD_OUT_EN	= (1 << 7),
	kDIALOG_ADC_CONTROL2_ADC_REF_EN		= (1 << 6),
	kDIALOG_ADC_CONTROL2_IBUCK1_EN		= (1 << 2),
	kDIALOG_ADC_CONTROL2_IBUCK0_EN		= (1 << 1),
	kDIALOG_ADC_CONTROL2_IBUS_EN		= (1 << 0),
};

enum {
	kDIALOG_ADC_CONTROL_DEFAULTS	= 0,
	kDIALOG_ADC_CONTROL2_DEFAULTS	= 0,
};

enum {
	kDIALOG_ADC_RESOLUTION_BITS	= 12,
	kDIALOG_ADC_FULL_SCALE_MV	= 2500,
	kDIALOG_ADC_BRICK_ID_OFFSET_MV	= 40,
};


enum {
    kDIALOG_BIST_ADC_CTRL_MAN_CONV		= (1 << 7),
    kDIALOG_BIST_ADC_CTRL_MUX_SEL_MASK	= (0x7f << 0),
    
//	From Table 65: BIST ADC measurement channel overview
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO1	= (0 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO1	= (1 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO2	= (2 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO2	= (3 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO3	= (4 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO3	= (5 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO4	= (6 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO4	= (7 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO5	= (8 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO5	= (9 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO6	= (10 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO6	= (11 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO7	= (12 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO7	= (13 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO8	= (14 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO8	= (15 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO9	= (16 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO9	= (17 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO13= (18 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO13= (19 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO11= (20 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO11= (21 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO10= (22 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO10= (23 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM1	= (24 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM1	= (25 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM2	= (26 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM2	= (27 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM3	= (28 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM3	= (29 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VRTC	= (30 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IRTC	= (31 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUF_ON	= (32 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0	= (34 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_WLEDB= (36 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK2	= (38 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK3	= (40 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK4	= (42 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_WLEDA= (44 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBOOST_LCM= (46 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_A	= (48 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_B	= (50 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK6	= (52 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK1	= (56 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK5	= (58 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_BUCK3_SW1	= (64 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_BUCK3_SW2	= (66 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_BUCK3_SW3	= (68 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_BUCK4_SW1	= (70 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_BUCK4_SW2	= (72 << 0),
};

enum {
	kDIALOG_APP_TMUX_SEL_MASK		= (7 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_0		= (0 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_1		= (1 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_2		= (2 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_3		= (3 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_4		= (4 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_5		= (5 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_6		= (6 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_7		= (7 << 0),
	KDIALOG_APP_TMUX_EN			= (1 << 7),
};

enum {
	kDIALOG_RTC_CONTROL_MONITOR		= (1 << 0),
	kDIALOG_RTC_CONTROL_ALARM_EN		= (1 << 6),
};

enum {
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_LOW		= (0 << 1),
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_HIGH		= (1 << 1),

	kDIALOG_SYS_GPIO_INPUT_WAKE			= (1 << 1),

	kDIALOG_SYS_GPIO_DIRECTION_MASK			= (7 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT			= (0 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT_32KHZ		= (2 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH	= (3 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_LOW		= (4 << 5),
};

#define IS_GPIO_OUTPUT(gpio) (((gpio)&kDIALOG_SYS_GPIO_DIRECTION_MASK) \
				< kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH)

enum {
	kDIALOG_WLED_CONTROL_WLED_ENABLE1	= (1 << 0),
	kDIALOG_WLED_CONTROL_WLED_ENABLE2	= (1 << 1),
	kDIALOG_WLED_CONTROL_WLED_ENABLE3	= (1 << 2),
	kDIALOG_WLED_CONTROL_WLED_ENABLE4	= (1 << 3),
	kDIALOG_WLED_CONTROL_WLED_ENABLE5	= (1 << 4),
	kDIALOG_WLED_CONTROL_WLED_ENABLE6	= (1 << 5),
};

enum {
	kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN	= (1 << 3),
	kDIALOG_WLED_CONTROL2_WLED_DITH_EN	= (1 << 2),
	kDIALOG_WLED_CONTROL2_WLED_DWI_EN	= (1 << 1),
	kDIALOG_WLED_CONTROL2_WLED_RAMP_EN	= (1 << 0),
	
	kDIALOG_WLED_CONTROL_WLED_DWI_EN	= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,
	
	kDIALOG_WLED_OPTIONS_DEFAULT		= kDIALOG_WLED_CONTROL2_WLED_DITH_EN,
	kDIALOG_WLED_OPTIONS_xWI_EN		= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,
	kDIALOG_WLED_OPTIONS_MASK		= (kDIALOG_WLED_CONTROL2_WLED_RAMP_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN),
};

#define WLED_ISET_BITS	(11)



#define NUM_LDOS 22
static const struct ldo_params ldo_d2089[NUM_LDOS] = {
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO1_VSEL,	 kD2089_ACTIVE3, 0x02 },	// LDO1
	{ 1200, 5,  0xff, 0xff, 0x04, kD2089_LDO2_VSEL,	 kD2089_ACTIVE3, 0x04 },	// LDO2
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO3_VSEL,	 kD2089_ACTIVE3, 0x08 },	// LDO3
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO4_VSEL,	 kD2089_ACTIVE3, 0x10 },	// LDO4
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO5_VSEL,	 kD2089_ACTIVE3, 0x20 },	// LDO5
	{ 1200, 25, 0x7f, 0x7f, 0x40, kD2089_LDO6_VSEL,	 kD2089_ACTIVE3, 0x40 },	// LDO6
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO7_VSEL,	 kD2089_ACTIVE3, 0x80 },	// LDO7
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO8_VSEL,	 kD2089_ACTIVE4, 0x01 },	// LDO8
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO9_VSEL,	 kD2089_ACTIVE4, 0x02 },	// LDO9
	{ 600,  12, 0xff, 0xff, 0x00, kD2089_LDO10_VSEL, kD2089_ACTIVE4, 0x04 },	// LDO10 - actually 12.5mv steps (FIXME)
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO11_VSEL, kD2089_ACTIVE4, 0x08 },	// LDO11
	{ 0,	0,  0,	  0,	0x00, 0,		 kD2089_ACTIVE4, 0x00 },	// there is no LDO12
	{ 1200, 25, 0x7f, 0x7f, 0x00, kD2089_LDO13_VSEL, kD2089_ACTIVE4, 0x20 },	// LDO13

	{ 5000, 50, 0x1f, 0x1f, 0x0, kD2089_LCM_BOOST_VSEL,kD2089_ACTIVE5, 0x04 },	// "LDO14" / LCM_LDO1
	{ 5000, 50, 0x1f, 0x1f, 0x0, kD2089_LCM_BOOST_VSEL,kD2089_ACTIVE5, 0x08 },	// "LDO15" / LCM_LDO2
	{ 5000, 50, 0x1f, 0x1f, 0x0, kD2089_LCM_BOOST_VSEL,kD2089_ACTIVE5, 0x10 },	// "LDO16" / LCM_LDO3

	{ 0,    0,  0,    0,    0x00, 0,		kD2089_ACTIVE6, 0x01 },		// "LDO17" - BUCK3_SW1_EN
	{ 0,    0,  0,    0,    0x00, 0,		kD2089_ACTIVE6, 0x02 },		// "LDO18" - BUCK3_SW2_EN
	{ 0,    0,  0,    0,    0x00, 0,		kD2089_ACTIVE6, 0x04 },		// "LDO19" - BUCK3_SW3_EN
	{ 0,    0,  0,    0,    0x00, 0,		kD2089_ACTIVE6, 0x10 },		// "LDO20" - BUCK4_SW1_EN
	{ 0,    0,  0,    0,    0x00, 0,		kD2089_ACTIVE6, 0x20 },		// "LDO21" - BUCK4_SW2_EN

	{ 0,    0,  0,    0,    0x00, 0,		kD2089_HIBERNATE3, 0x40 },	// "LDO22" - set LDO6_EN in HIB
};
#define LDOP ldo_d2089

enum {
	kDIALOG_VIB_CTRL_PWM_EN			= (1 << 0),
	kDIALOG_VIB_CTRL_BRAKE			= (1 << 1),
	kDIALOG_VIB_CTRL_PWM_CLK_MASK		= (3 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_2MHZ		= (0 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_1MHZ		= (1 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_500KHZ		= (2 << 2),

	kDIALOG_VIB_VSET_MASK			= (0x3f << 0),
};

enum {
	kDIALOG_SYS_CONFIG_WDOG_EN		= (1 << 0),

	kDIALOG_SYS_CONFIG_WDOG_MODE_100MS	= (0 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_250MS	= (1 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_500MS	= (2 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_1000MS	= (3 << 1),

	kDIALOG_SYS_CONFIG_RESET_TIMER_MASK	= (3 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_4S	= (0 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_6S	= (1 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_8S	= (2 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_10S	= (3 << 3),
	
	kDIALOG_SYS_CONFIG_WDOG_ACTIVE		= (1 << 5),
};

enum {
	kDIALOG_BUTTON_DBL_CLICK_RATE_MASK	= (7 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_50MS	= (0 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_100MS	= (1 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_150MS	= (2 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_200MS	= (3 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_250MS	= (4 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_300MS	= (5 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_350MS	= (6 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_400MS	= (7 << 0),
	kD2089_BUTTON_DBL_BTN1_DBL_EN		= (1 << 3),
	kD2089_BUTTON_DBL_BTN2_DBL_EN		= (1 << 4),
	kD2089_BUTTON_DBL_BTN3_DBL_EN		= (1 << 5),
	kD2089_BUTTON_DBL_BTN4_DBL_EN		= (1 << 6),
	kDIALOG_BUTTON_DBL_HOLD_DBL_EN		= kD2089_BUTTON_DBL_BTN2_DBL_EN,
	kDIALOG_BUTTON_DBL_MENU_DBL_EN		= kD2089_BUTTON_DBL_BTN1_DBL_EN,
	kDIALOG_BUTTON_DBL_RINGER_DBL_EN	= kD2089_BUTTON_DBL_BTN3_DBL_EN,
};

#endif /* __DIALOG_D2089_H */
